package cn.thinkcloud.corpwx.worksign.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.thinkcloud.corpwx.worksign.component.ScheduledRunnable;
import cn.thinkcloud.corpwx.worksign.service.UpdateAccessTokenScheduleTask;

@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    @Qualifier("updateAccessToken")
    ScheduledRunnable updateAccessTokenScheduleTask;
    
	@RequestMapping(value = "/view")
	public String indexPage(Map<String,Object> map) {
        
        map.put("msg", "Qiye Weixin");
        map.put("access_token", 
        		((UpdateAccessTokenScheduleTask)updateAccessTokenScheduleTask).getAccessToken());
		System.out.println("indexPage");
		return "index";
	}
	
    @GetMapping("/helloworld")
    @ResponseBody
    public String helloworld(Map<String,Object> map) {
        map.put("msg", "Qiye Weixin");
        map.put("access_token", 
        		((UpdateAccessTokenScheduleTask)updateAccessTokenScheduleTask).getAccessToken());
		System.out.println("helloworld");
        return "index";
    }

}
